home *** CD-ROM | disk | FTP | other *** search
- {************************************************}
- { }
- { E! for Windows }
- { (c) - Patrick Philippot - 1992,1993 }
- { }
- { MulHelp2 Extension DLL - version 2.1 }
- { }
- { Supporting multiple Help Files from E!. }
- { }
- {************************************************}
-
- (*
- MULHELP2 is a much more sophisticated version of MULHELP. There are
- many situations where you have to refer to multiple help files. For
- example, when writing Visual C++ source code with E!, you may want
- to refer to the Windows 3.1 SDK, the MFC 2.5 and the C/C++ language
- help files. It would be nice to load one of this file at will when
- the cursor is located on a keyword.
-
- With MULHELP2 you can.
-
- With MULHELP, each alternate help file was assigned a different key.
- MULHELP2 has another approach. When you hit SHIFT+F1 (or the key that
- you have assigned to the AlternateHelp function), a listbox is
- displayed, showing the list of all the alternate help files that you
- have specified in EW.INI. Select one of these and WinHelp will be
- called with the selected help file and the current keyword as
- parameters.
-
- But there's more to MULHELP2, however. This DLL installs a hook on the
- JumpToDefinition function. When you ask E! to jump to a function definition
- and when E! can't find this definition in the TAG file, MULHELP2 takes
- control and asks the user whether he wants the keyword to be passed to
- one of the registered help files.
-
-
- Installing MULHELP2
- *******************
-
- The first thing you have to do is to create a new section in EW.INI:
- [extended help]. Then, you will list in that section the help files
- you want to use, as follows (this is an example):
-
- HelpName1=win31wh.hlp
- HelpName2=mfc.hlp
- HelpName3=mscxx.hlp
-
- You must then add a description for each of these files:
-
- HelpDesc1=Windows SDK Help File
- HelpDesc2=MFC 2.5 Help File
- HelpDesc3=Microsoft C/C++ Language Help File
-
- and so on...
-
- You should then load MULHELP2 from the User menu (you can also
- install MULHELP2 as an autoloaded EWD). MULHELP2.EWD must reside in
- your USER directory.
-
- WARNING!!
-
- If you had previously installed MULHELP.EWD, you should unload it,
- remove it from your autoload list if necessary and remove any
- assignment to the SHIFT+F1 key (or to the key to which you have
- assigned the AlternateHelp function).
-
- Once MULHELP2 is loaded, when you hit SHIFT+F1, the list of help
- file descriptors will be displayed and you'll just have to select
- one to get help about the current keyword if it is relevant for the
- selected help file.
-
-
- Enjoy!
-
- Patrick Philippot
- 04/22/94
- *)
-
- {$I compdir.inc}
- {$C MOVEABLE PRELOAD DISCARDABLE}
- {$R mulhelp2.res}
-
- library MulHelp;
-
- uses WinProcs, WinTypes, EWApImp2, Strings;
-
- {$I ewuser.inc}
-
- const
- HelpEntry : PChar = 'HelpName';
- HelpDesc : PChar = 'HelpDesc';
- HelpSection : PChar = 'Extended Help';
- Profile : PChar = 'ew.ini';
-
- id_Listbox = 100;
-
- var
- EntryValue : array[0..80] of char;
- HelpCurEntry : array[0..80] of char;
- SaveExit : Pointer;
- ListBoxHandle : THandle;
- OkBtHandle : THandle;
- ChoiceProc : TFarProc;
-
-
- function ChoiceDlg(Dialog: HWnd; Message, WParam: Word; LParam: Longint): Bool; export;
- {-This is the dialog procedure managing the Help File Description List}
-
- var
- Index : integer;
- IndexStr : array[0..3] of char;
-
- label
- OKSelect;
-
- begin
- ChoiceDlg := True;
- case Message of
- wm_InitDialog:
- begin
- {-Get handle of Listbox}
- ListBoxHandle := GetDlgItem(Dialog, id_ListBox);
- OkBtHandle := GetDlgItem(Dialog, id_Ok);
- EnableWindow(OkBtHandle, false);
- SetFocus(ListBoxHandle);
- {-Fill listbox with name of registered help files}
- Index := 1;
- Str(Index, IndexStr);
- StrCat(StrCopy(HelpCurEntry, HelpDesc), IndexStr);
- {-Iterate through list of help file descriptors}
- while GetPrivateProfileString(HelpSection,
- HelpCurEntry,
- '',
- EntryValue,
- SizeOf(EntryValue),
- Profile) <> 0 do begin
- {-Add descriptor to Listbox}
- SendMessage(ListBoxHandle, lb_AddString, 0, longint(Addr(EntryValue)));
- Inc(Index);
- Str(Index, IndexStr);
- StrCat(StrCopy(HelpCurEntry, HelpDesc), IndexStr);
- end;
- end;
- wm_Command:
- begin
- case WParam of
- id_Listbox:
- if HiWord(LParam) = lbn_DblClk then
- Goto OKSelect
- else if HiWord(LParam) = lbn_SelChange then
- EnableWindow(OkBtHandle, true);
- id_Ok:
- begin
- OkSelect:
- Index := SendMessage(ListBoxHandle, lb_GetCurSel, 0, 0);
- if Index <> lb_Err then begin
- {-A Help File Descriptor is currently selected}
- Str(Index + 1, IndexStr);
- StrCat(StrCopy(HelpCurEntry, HelpEntry), IndexStr);
- {-Get the corresponding help filename}
- if GetPrivateProfileString(HelpSection,
- HelpCurEntry,
- '',
- EntryValue,
- SizeOf(EntryValue),
- Profile) <> 0 then begin
- {-It is important to close the dialog box before calling an E! API
- function. Otherwise, E! is unable to know which Edit Window is active}
- EndDialog(Dialog, id_Ok);
- WritePrivateProfileString('system',
- 'alternatehelp',
- EntryValue,
- Profile);
- EWAlternateHelp(EWGetCaretPosX, EWGetCaretPosY);
- Exit;
- end else begin
- {-No Help Filename could be found for the Descriptor with this index}
- MessageBeep(0);
- EWMessageBox(GetFocus,
- 'Can''t find related Help File.',
- 'Error!',
- mb_Ok or mb_IconExclamation);
- end;
- end else begin
- MessageBeep(0);
- EWMessageBox(GetFocus,
- 'No Help File Selected.',
- 'Error!',
- mb_Ok or mb_IconExclamation);
- end;
- end;
- id_Cancel:
- begin
- EndDialog(Dialog, id_Cancel);
- Exit;
- end;
- end;
- end;
- end;
- ChoiceDlg := False;
- end;
-
- function FuncEntryHook(command : word) : integer; export;
- {-Install a hook for the AlternateHelp function. }
-
- const
- bInUse : boolean = false;
-
- begin
- if not bInUse and (command = ew_AlternateHelp) then begin
- FuncEntryHook := 1;
- bInUse := true;
- ChoiceProc := MakeProcInstance(@ChoiceDlg, HInstance);
- DialogBox(HInstance, 'HelpList', GetFocus, ChoiceProc);
- FreeProcInstance(ChoiceProc);
- bInUse := false;
- end else
- FuncEntryHook := 0;
- end;
-
- function FuncExitHook(command : word; pRetCode : PInteger) : integer; export;
- {-Check whether the JumpToDef function succeeded.}
- { If not, ask the user whether the keyword should passed to a help file}
-
- begin
- FuncExitHook := 0;
- {-Although the current version of the EW API doesn't check the return code}
- { from the FuncExitHook functions, it is good practice to set this value }
- { to 0.}
- if (command = ew_MCJumpToDef) and (pRetcode^ <> 0) then
- if EwMessageBox(GetFocus,
- 'No Definition found for this function. Pass Keyword to a Help File?',
- 'Error',
- mb_YesNo) = id_Yes then
- pRetcode^ := EWAlternateHelp(EWGetCaretPosX, EWGetCaretPosY);
- end;
-
- procedure LibExit; far;
- begin
- {-Uninstall Hook before exiting}
- EWRemoveHook(EWHook_FunctionEntry, @FuncEntryHook);
- EWRemoveHook(EWHook_FunctionExit, @FuncExitHook);
- ExitProc := SaveExit;
- end;
-
- exports
- FuncEntryHook index 1;
-
- begin
- {-Install Function Entry Hook on the AlternateHelp function}
- EWSetHook(EWHook_FunctionEntry, @FuncEntryHook);
- EWSetHook(EWHook_FunctionExit, @FuncExitHook);
- SaveExit := ExitProc;
- ExitProc := @LibExit;
- end.
-